Fixed jade errors and refactored