refactored a bit but stil ain't working