Removed two circuitous nested function calls for efficiency's sake