Improved loadOwnFunction function to check whether libraryPath exists