refactored some methods to be faster