Fixed issues, works correctly now