removed the error, refactored a bit