Improve prev code