solved it badly but working