Code working, but very bad working