improve front logic