logic improvments