removed duplicate function and added more docs