Modified to work with library