Separate logic to a library