refactor code to enhance consistancy