Refactored linking to one function + optimalization