Refactored obstacles codes into its own class