Added a launcher check and reformatted/optimized the code