Attempted herd behaviour and refactored some code