Cleaned up buddylib function