refactored to accept arguments