added new functions and fixed previous implementations