Started to use jQuery and moved code to $(document).ready