Replaced dumb code with good code -_-