prototype: better function separation and cleaner code