Refactored some more. Created one createLayer function and one function to set the blackbox html