inline some function to improve speed