perfect code according to @Mooophy's advice.