move styles to stylesheet
fix index calculations