Streamlined code + updated incorrect MySQL syntax