use internal functions to speed up, not too effective in reading tho…