Refactored to be more Java friendly