Improve homepage logic