[Fixed] refactored a bit of code in the process of fixing Issue #21