Updated Code, got rid of redundant-ness, made smaller