Refactored for easier management of common functions